<template>
  <div>
    <svg-icon v-if="flag" icon-class="fullscreen" class="svgScreen" @click="clickFullScreen" />
    <svg-icon v-else icon-class="exit-fullscreen" class="svgScreen" @click="clickFullScreen" />
  </div>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  data() {
    return {
      flag: true
    }
  },
  methods: {
    clickFullScreen() {
      // 查看是否支持全屏
      if (ScreenFull.isEnabled) {
        // 支持
        ScreenFull.toggle()
        this.flag = !this.flag
      } else {
        // 不支持
        this.$message.error('兄弟, 您的浏览器版本过低, 不支持全屏功能哦!')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.svgScreen {
  fill: #fff !important;
  cursor: pointer;
}
</style>
